package smallchange;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Service {
    double money = 0;
    String state = "";//明细
    double balance = 0;//余额
    Scanner scanner = new Scanner(System.in);
    Date date = null;//日期
    //改日期的格式
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");

    //零钱通明细
    public void Detail() {
        //System.out.println(state + " \t+" + money + + "\t余额" + balance);
        System.out.println(state);
    }

    //收益入账
    public void IncomeRecorded() {
        System.out.print("\n入账金额：");
        money = scanner.nextDouble();
        //校验入账金额
        if (money > 0) {
            balance += money;
            state += "\n收益入账\t+" + money + "\t" + sdf.format(date) + "\t余额：" + balance;
        }
    }

    //消费
    public void consumption() {

        System.out.print("\n消费金额：");
        money = scanner.nextDouble();
        if(money < balance || money == 0){
            System.out.print("\n消费说明：");
            state += "\n"+scanner.next() + "\t - " + money + "\t" +sdf.format(date) + "\t余额" + balance;
        }
    }

    //退出前询问
//    public void ask() {
//        while (true) {
//            System.out.println("你确认要退出吗？ y/n");
//            String input = scanner.next();
//            if(input == "y" || input == "n"){
//                return;
//            }
//        }
//    }
}
